//
//  PhoneNumberViewController.m
//  南京大牌档
//
//  Created by student on 13-12-26.
//  Copyright (c) 2013年 无锡第三团队. All rights reserved.
//

#import "PhoneNumberViewController.h"
#import "MainViewController.h"

@interface PhoneNumberViewController ()

@end

@implementation PhoneNumberViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        self.hidesBottomBarWhenPushed=YES;
        self.tabBarController.tabBar.hidden=YES;
    }
    return self;
}
-(void)loadView
{
    UIView *view = [[UIView alloc]initWithFrame:[UIScreen mainScreen] .applicationFrame];
    view.backgroundColor = [UIColor whiteColor];
    self.view = view;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
    {
        self.edgesForExtendedLayout = UIRectEdgeNone;
        self.extendedLayoutIncludesOpaqueBars = NO;
        self.modalPresentationCapturesStatusBarAppearance = NO;
    }
#endif

    
    PnTableView=[[UITableView alloc]initWithFrame:CGRectMake(0, 0, WXHLApplicationBounds().size.width, WXHLApplicationBounds().size.height-64) style:UITableViewStylePlain];

    
    PnTableView.delegate=self;
    PnTableView.dataSource=self;
    self.title=@"大牌档店铺电话地址";

    [self.view addSubview:PnTableView];
    
    NSDictionary *row1=@{@"title:":@"南京狮子桥店",@"Img:":@"szq.jpg"};
    NSDictionary *row2=@{@"title:":@"南京德基广场店",@"Img:":@"dj.jpg"};
    NSDictionary *row3=@{@"title:":@"南京中山陵店",@"Img:":@"zsl.jpg"};
    NSDictionary *row4=@{@"title:":@"南京国际广场店",@"Img:":@"gjgc.jpg"};
    NSDictionary *row5=@{@"title:":@"南京龙江店",@"Img:":@"lj.jpg"};
    NSDictionary *row6=@{@"title:":@"南京夫子庙平江府店",@"Img:":@"pjf.jpg"};
    NSDictionary *row7=@{@"title:":@"南京夫子庙水平方店",@"Img:":@"spf.jpg"};
    NSDictionary *row8=@{@"title:":@"南京江宁万达店",@"Img:":@"jlwd.jpg"};
    
    NSDictionary *row9=@{@"title:":@"北京中关村店",@"Img:":@"zgc.jpg"};
    NSDictionary *row10=@{@"title:":@"北京世贸百货店",@"Img:":@"smbh.jpg"};
    NSDictionary *row11=@{@"title:":@"北京凯德晶品店",@"Img:":@"kdjp.jpg"};
    NSDictionary *row12=@{@"title:":@"北京崇文门国瑞店",@"Img:":@"gr.jpg"};
    NSDictionary *row13=@{@"title:":@"北京西直门凯德店",@"Img:":@"xzm.jpg"};
    
    
    SectionOne = [[NSArray alloc]initWithObjects:row1,row2,row3,row4,row5,row6,row7,row8, nil];
    SectionTwo = [[NSArray alloc]initWithObjects:row9,row10,row11, row12,row13,nil];
    PnCellArray=[[NSArray alloc]initWithObjects:SectionOne,SectionTwo, nil];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section==0) {
        return 8;
    }
    else
        return 5;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
    if (section==0) {
        return @"南京";
    }
    else
        return @"北京";

}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *identifer=@"Cell";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifer];
    if(cell==nil)
    {
        cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifer];
    }
    cell.imageView.image=[UIImage imageNamed:[PnCellArray[indexPath.section][indexPath.row] objectForKey:@"Img:"]];
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.textLabel.text =[PnCellArray[indexPath.section][indexPath.row] objectForKey:@"title:"];
        [cell setEditing:YES animated:YES ];
        [ cell setEditing: NO animated:YES ];
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSMutableArray *njArray=[[NSMutableArray alloc]init];
    NSMutableArray *bjArray=[[NSMutableArray alloc]init];
    
    [njArray addObject:@"telprompt://02583305777"];
    [njArray addObject:@"telprompt://02584722777"];
    [njArray addObject:@"telprompt://02552335777"];
    [njArray addObject:@"telprompt://02583585777"];
    [njArray addObject:@"telprompt://02586218777"];
    [njArray addObject:@"telprompt://02568216777"];
    [njArray addObject:@"telprompt://02568176777"];
    [njArray addObject:@"telprompt://02568156777"];
    
    [bjArray addObject:@"telprompt://01059863111"];
    [bjArray addObject:@"telprompt://01084059777"];
    [bjArray addObject:@"telprompt://01088178777"];
    [bjArray addObject:@"telprompt://01087555777"];
    [bjArray addObject:@"telprompt://01058301555"];
    
    NSMutableArray *numArray=[[NSMutableArray alloc]initWithObjects:njArray,bjArray,nil];
    
    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:numArray[indexPath.section][indexPath.row]]];
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 40;

}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
